package com.fastwire.carriere.service;

import javax.jws.WebService;

import com.fastwire.carriere.common.Messages;
import com.fastwire.carriere.common.util.CommonLogger;
import com.fastwire.carriere.controller.ServiceOrderController;
import com.fastwire.carriere.controller.impl.ServiceOrderControllerImpl;
import com.fastwire.carriere.pegasus.vo.PegasusOrderDetailsVo;
import com.fastwire.carriere.service.dataconverter.XMLConverter;
import com.fastwire.carriere.service.exception.FaultInfo;
import com.fastwire.carriere.service.exception.ServiceException;
import com.fastwire.carriere.service.validator.PegasusOrderInputValidator;

// TODO: Auto-generated Javadoc
/*
 * create by Jun on 20120112
 */
/**
 * The Class PegasusServiceImpl.
 */
@WebService(endpointInterface = "com.fastwire.carriere.service.PegasusService")
public class PegasusServiceImpl implements PegasusService {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.fastwire.carriere.service.PegasusService#createOrder(com.fastwire
	 * .carriere.pegasus.vo.PegasusOrderDetailsVo)
	 */
	@Override
	public String createOrder(PegasusOrderDetailsVo order)
			throws ServiceException {

		String msg = Messages.getString("message.common.service.success");

		ServiceOrderController controller = new ServiceOrderControllerImpl();
		try {

			CommonLogger.info(this, XMLConverter.serilizeObjectToXML(order));
			PegasusOrderInputValidator.validateServiceOrder(order);
			controller.createServiceOrder(order);
		} catch (Throwable e) {
			throw new ServiceException(e.getMessage(), new FaultInfo(
					e.getMessage()));
		}

		return msg;
	}
}
